import { err } from "~/utils/wxapi";
import { NoticeList } from "~/apis/notice";
Page({
  data: { list: [] },
  onLoad() {
    this.getlist()
  },
  onShow() {
    if (typeof this.getTabBar === "function" && this.getTabBar()) {
      this.getTabBar().setData({
        selected: 2,
      });
    }
  },
  async getlist() {
    try {
      const res: any = await NoticeList();
      console.log(res);
      if (res.code === 200) {
        this.setData({ list: res.data.item })
      }
    } catch (error) {
      console.log(error)
      err(error);
    }
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  async onPullDownRefresh() {
    await this.getlist();
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() { },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() { },
});
